<%@page import="untiring07.j2ee.basic._07SungJukVO"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>액션태그로 처리하는 성적프로그램</title>
</head>
<body>
<h1>액션태그로 처리하는 성적프로그램</h1>
<h3>JSP 스크립트릿만으로 작성</h3>
<%
	request.setCharacterEncoding("UTF-8");
	String name = 
		request.getParameter("name");
	int kor =
		Integer.parseInt(
	request.getParameter("kor")) ;
	int eng =
		Integer.parseInt(
		request.getParameter("eng"));
	int mat =
		Integer.parseInt(			
		request.getParameter("mat"));
	
	int tot = kor + eng + mat;
	float avg = tot / 3;
	String grd = "가";
	switch( (int)avg/10 ){
		case 10:case 9: 
		grd = "수"; break;
		case 8: grd = "우"; break;
		case 7: grd = "미"; break;
		case 6: grd = "양";
	}
%>
<p>이름 : <%=name%></p>
<p>국어 : <%=kor%></p>
<p>영어 : <%=eng%></p>
<p>수학 : <%=mat%></p>
<p>총점 : <%=tot%></p>
<p>평균 : <%=avg%></p>
<p>학점 : <%=grd%></p>
<hr />
<h3>자바빈즈 클래스로 작성</h3>
<%
	request.setCharacterEncoding("UTF-8");
	_07SungJukVO sj = new _07SungJukVO();
	sj.setName(request.getParameter("name"));
	sj.setKor( Integer.parseInt(
		request.getParameter("kor") ) );
	sj.setEng( Integer.parseInt(
		request.getParameter("eng") ) );
	sj.setMat( Integer.parseInt(
		request.getParameter("mat") ) );
%>
<p>이름 : <%=sj.getName()%></p>
<p>국어 : <%=sj.getKor()%></p>
<p>영어 : <%=sj.getEng()%></p>
<p>수학 : <%=sj.getMat()%></p>
<p>총점 : <%=sj.getTot()%></p>
<p>평균 : <%=sj.getAvg()%></p>
<p>학점 : <%=sj.getGrd()%></p>
<hr />
<h3>자바빈즈 클래스 + 액션태그로 작성</h3>
<%
	request.setCharacterEncoding("UTF-8");
%>
<jsp:useBean id="sj2" 
class="untiring07.j2ee.basic._07SungJukVO"
scope="page" />
<%-- <jsp:setProperty 
	property="name" name="sj2"
	value=
	"<%=request.getParameter("name") %>" /> --%>

<%-- <jsp:setProperty 
	property="name" name="sj2" />
<jsp:setProperty 
	property="kor" name="sj2" />
<jsp:setProperty 
	property="eng" name="sj2" />
<jsp:setProperty 
	property="mat" name="sj2" /> --%>
			
<jsp:setProperty property="*" name="sj2"/>			
				
<p>이름 : <jsp:getProperty 
	property="name" name="sj2"/> </p>
<p>국어 : <%=sj2.getKor()%></p>
<p>영어 : <%=sj2.getEng()%></p>
<p>수학 : <%=sj2.getMat()%></p>
<p>총점 : <%=sj2.getTot()%></p>
<p>평균 : <%=sj2.getAvg()%></p>
<p>학점 : <%=sj2.getGrd()%></p>
<hr />
<h3>자바빈즈 클래스 + 액션태그 + EL로 작성</h3>
<%
	request.setCharacterEncoding("UTF-8");
%>
<jsp:useBean id="sj3" 
class="untiring07.j2ee.basic._07SungJukVO"
scope="page" />
<jsp:setProperty property="*" name="sj3"/>			
				
<p>이름 : ${ sj3.name } </p>
<p>국어 : ${ sj3.kor }</p>
<p>영어 : ${ sj3.eng }</p>
<p>수학 : ${ sj3.mat }</p>
<p>총점 : ${ sj3.tot }</p>
<p>평균 : ${ sj3.avg }</p>
<p>학점 : ${ sj3.grd }</p>

</body>
</html>


